<script  setup>
import { ref } from 'vue'
import $ from 'jquery'

const show = ref(false)
function close() {
  show.value = false
}
function showModal(...html) {
  show.value = true
  do {
    setTimeout(() => {
      $('.container').empty()
      $('.container').html(html)
    }, 200)
  } while ($('.container').length <= 0)
}
defineExpose({
  showModal,
})
</script>

<template>
  <div v-if="show" class="modal">
    <div class="wrap" @click="close">
      <div class="box">
        <div class="modal-box__header" @click.stop="">
          预览
        </div>
        <div class="preview-body" style="max-height: 50vh; overflow: auto;">
          <div class="container" />
        </div>
        <div class="modal-box__footer">
          <button class="primary" @click="close">
            确定
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<style>
/* 不同模板 间隙 */
.container .hiprint-printTemplate {
  background: #fff;
  border-bottom: 10px solid #ccc;
}

/* 批量打印 间隙 */
.container .hiprint-printTemplate .hiprint-printPanel:not(:last-of-type) {
  border-bottom: 5px solid #ccc;
}
</style>

<style scoped>
.preview-body {
  display: flex;
  justify-content: center;
  padding: 14px 0;
  background: #ccc;
}
</style>
